******************************************************************************************************
******************************************************************************************************
//-----------------------------DEMOCRACY AND MASS SKEPTICISM OF SCIENCE-----------------------------//
//-------------------------------------  WORLD POLITICS  -------------------------------------------//
//------------------------------ For Replication and Publication -----------------------------------//
//------------------------ (Constitutions & Honors Table 5, A.2, A.21) -----------------------------//
******************************************************************************************************
******************************************************************************************************
//---------------NOTES---------------//
** Author: Junyan Jiang, Kin-Man Wan
** Last Updated: 
** Environment: 
*** Stata 17 SE
*** Windows 11 x64, AMD Ryzen 7 4800HS
*** 16GB RAM


//---------------TABLE 5: Analysis of Constitutional Texts and National Honors ---------------//
** Constitutional Texts
use "DATA_WP_jiang_wan_constitutions", clear 

eststo m1: reg dens_sci2   demo_t   ,robust

eststo m2: reghdfe dens_sci2   loggdppc loglength demo_t     ,   a(un_region  year) keepsingle
estadd local rfe "$\checkmark$"
estadd local yfe "$\checkmark$"
estadd local ctrl "$\checkmark$"

eststo m3: reghdfe dens_sci2   loggdppc loglength v2x_polyarchy   ,    a(un_region  year) keepsingle
estadd local rfe "$\checkmark$"
estadd local yfe "$\checkmark$"
estadd local ctrl "$\checkmark$"

eststo m4: reghdfe dens_sci2   loggdppc loglength i.e_fh_status   ,    a( un_region year) keepsingle
estadd local rfe "$\checkmark$"
estadd local yfe "$\checkmark$"
estadd local ctrl "$\checkmark$"

** State Award 
use "DATA_WP_jiang_wan_honors", clear

eststo m5: reg sci_nom_honor    demo_t    , cluster(iso3)
sum sci_nom_honor if e(sample)

eststo m6: reghdfe sci_nom_honor   demo_t loggdp_v2  logpop_v2   log_nom_awards   ,a(year  iso3 ) cluster(iso3)
estadd local cfe "$\checkmark$"
estadd local yfe "$\checkmark$"
estadd local ctrl "$\checkmark$"

eststo m7: reghdfe sci_nom_honor   v2x_polyarchy loggdp_v2  logpop_v2   log_nom_awards  ,a(year  iso3   ) cluster(iso3)
estadd local cfe "$\checkmark$"
estadd local yfe "$\checkmark$"
estadd local ctrl "$\checkmark$"

eststo m8: reghdfe sci_nom_honor   i.e_fh_status loggdp_v2  logpop_v2   log_nom_awards   ,a(year  iso3 ) cluster(iso3)
estadd local cfe "$\checkmark$"
estadd local yfe "$\checkmark$"
estadd local ctrl "$\checkmark$"

esttab m1 m2 m3 m4 m5 m6 m7 m8  using out.txt, nonote   nogap keep(demo_t   v2x_polyarchy *e_fh_status ) b(3) se(3) ///
order( demo_t   v2x_polyarchy *e_fh_status )  star(+ 0.1 * 0.05 ** 0.01) label booktabs replace   ///
nomtitles refcat(1.e_fh_status "\emph{Freedom House Status}"  ,nolabel)     ///
mgroup("DV: Constitutional reference to science per 1,000 words" "DV: \% of State honors to scientists"  , pattern(1 0 0 0  1 0 0 0 ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span})) ///
stats(yfe rfe cfe  ctrl r2_a  N, labels("Year FE" "Region FE" "Country FE" "Control variables" "Adjusted R$^2$"  "Observations") fmt( 0 0 0 0 2 0 ) )


//---------------TABLE A.21: Science Honors and Trust in Science among the Less Educated ---------------//
use "DATA_WP_jiang_wan_honor_trust", clear

eststo clear
eststo m1: reg y_ledu   sci_share2 total_honor logpop loggdppc  y_hedu , robust

eststo m2: reghdfe y_ledu   sci_share2 total_honor logpop loggdppc  y_hedu  , a(region)
estadd local rfe "$\checkmark$"

eststo m3: reg y_medu  sci_share2  total_honor logpop loggdppc  y_hedu , robust

eststo m4: reghdfe y_medu    sci_share2  total_honor  logpop loggdppc  y_hedu  , a(region)
estadd local rfe "$\checkmark$"

esttab m1 m2 m3 m4   using out.txt, nonote   nogap keep(sci_share2 total_honor logpop loggdppc  y_hedu) b(3) se(3) ///
order( sci_share2 total_honor logpop loggdppc  y_hedu )  star(+ 0.1 * 0.05 ** 0.01) label booktabs replace   ///
mgroup("DV: Average Trust in science (primary education or below)" "DV: Average Trust in science (secondary education)"  , pattern(1 0  1 0  ) prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}))  nomtitles ///
stats(  rfe      r2_a  N, labels(  "Region FE"  "Adjusted R$^2$"  "Observations") fmt( 0 2 0 ) )


//---------------TABLE A.2: Summary Statistics for Constitutional Texts and State Honors ---------------//
**Constitutional Texts
use "DATA_WP_jiang_wan_constitutions", clear
global sum1 dens_sci2   demo_t  loglength   e_polity2 v2x_polyarchy e_fh_status year
eststo summ: estpost summarize  $sum1 
esttab summ using out.txt, booktabs ///
nomtitle nonumber noobs cells("mean(fmt(a2)) sd(fmt(a2)) min max count") replace label 

use "DATA_WP_jiang_wan_honors", clear
global sum2 sci_nom_honor   demo_t   log_nom_awards v2x_polyarchy e_fh_status year
eststo summ: estpost summarize  $sum2 if sci_nom_honor!=.
esttab summ using out.txt , booktabs ///
nomtitle nonumber noobs cells("mean(fmt(a2)) sd(fmt(a2)) min max count") replace label  



